package com.fjnu.javaweb.service;

import com.fjnu.javaweb.Loggable;
import com.fjnu.javaweb.entity.Product;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class ShoppingCartService {
    List<Product> products = new ArrayList<>();

    public boolean add(Product product) {
        if(product == null){
            return false;
        }
        boolean success = products.add(product);
        return success;
    }

    public boolean remove(String id){
        //TODO 根据id移除商品，而不是下标
        boolean success = products.remove(id);
        return success;
    }

    @Loggable
    public List<Product> listAll(){
        return products;
    }
}
